#ifndef __L0032_0_PARSER_H__
#define __L0032_0_PARSER_H__


#define L0032_PARSER_CONTEXT_BUFLEN     128
struct l0032_parser_context {
	char nodename[L0032_PARSER_CONTEXT_BUFLEN];
    char expect[L0032_PARSER_CONTEXT_BUFLEN];   // expected field
    char errmessage[L0032_PARSER_CONTEXT_BUFLEN];
};

struct l0032_iniconf_parser {
	struct l0032_parser_context *context;
	int ncontext;	// stack max depth
	int top;	// top stack index
};

void l0032_reinit_iniconf_parser(struct l0032_iniconf_parser *parser, int maxdepth);
void l0032_iniconf_context_push(struct l0032_iniconf_parser *parser, const char* stream, ...);
void l0032_iniconf_context_pop(struct l0032_iniconf_parser *parser);
void l0032_parser_dump(struct l0032_iniconf_parser *parser);
void l0032_iniconf_clear_expect(struct l0032_iniconf_parser *parser, const char* expect);
void l0032_iniconf_set_expect(struct l0032_iniconf_parser *parser, const char* stream, ...);
void l0032_iniconf_set_errmessage(struct l0032_iniconf_parser *parser, const char* stream, ...);
void l0032_iniconf_clear_errmessage(struct l0032_iniconf_parser *parser);

#define CONTEXT_PUSH(FMT,ARGS...) do {\
    l0032_iniconf_context_push(&iniconf_parser, FMT, ##ARGS);\
} while(0);
#define CONTEXT_POP() do {\
    l0032_iniconf_context_pop(&iniconf_parser);\
} while(0);

#define CONTEXT_EXPECT(FMT,ARGS...) do {\
    l0032_iniconf_set_expect(&iniconf_parser, FMT, ##ARGS);\
} while(0);

#define CONTEXT_ERRMESSAGE(FMT,ARGS...) do {\
    l0032_iniconf_set_errmessage(&iniconf_parser, FMT, ##ARGS);\
} while(0);

#endif